import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;

/**
 * 数据库连接池接口，转换为默认方法，当子类抽象连接池继承该接口时，仅仅复写getConnection()
 *
 * @author HHLJ
 * @date 2022/03/15
 */
public interface MyDataSource extends DataSource {
    /**
     * 获得连接
     *
     * @return {@link Connection}
     * @throws SQLException sqlexception异常
     */
    @Override
    default Connection getConnection() throws SQLException {
        return null;
    }

    /**
     * 获得连接
     *
     * @param username 用户名
     * @param password 密码
     * @return {@link Connection}
     * @throws SQLException sqlexception异常
     */
    @Override
    default Connection getConnection(String username, String password) throws SQLException {
        return null;
    }

    /**
     * 打开
     *
     * @param clazz clazz
     * @return {@link T}
     * @throws SQLException sqlexception异常
     */
    @Override
    default <T> T unwrap(Class<T> clazz) throws SQLException {
        return null;
    }

    /**
     * 是包装的
     *
     * @param clazz clazz
     * @return boolean
     * @throws SQLException sqlexception异常
     */
    @Override
    default boolean isWrapperFor(Class<?> clazz) throws SQLException {
        return false;
    }

    /**
     * 获取日志作家
     *
     * @return {@link PrintWriter}
     * @throws SQLException sqlexception异常
     */
    @Override
    default PrintWriter getLogWriter() throws SQLException {
        return null;
    }

    /**
     * 设置日志作家
     *
     * @param out 出
     * @throws SQLException sqlexception异常
     */
    @Override
    default void setLogWriter(PrintWriter out) throws SQLException {

    }

    /**
     * 设置登录超时
     *
     * @param seconds 秒
     * @throws SQLException sqlexception异常
     */
    @Override
    default void setLoginTimeout(int seconds) throws SQLException {

    }

    /**
     * 获得登录超时
     *
     * @return int
     * @throws SQLException sqlexception异常
     */
    @Override
    default int getLoginTimeout() throws SQLException {
        return 0;
    }

    /**
     * 得到父类记录器
     *
     * @return {@link Logger}
     * @throws SQLFeatureNotSupportedException sqlfeature不支持例外
     */
    @Override
    default Logger getParentLogger() throws SQLFeatureNotSupportedException {
        return null;
    }
}

